﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
using System;
using System.IO;

namespace MCSharp.Network.Handlers
{
    public class SwitchHandler : PacketHandler
    {

        #region PacketHandler Members

        public void Handle(BinaryReader reader, Session session, Player player)
        {
            int playerID = PacketWriter.SwapEndian(reader.ReadUInt32());
            short itemID = PacketWriter.SwapEndian(reader.ReadInt16());
            Server.SendToOthersInRange(PacketWriter.MakeSwitch(player, itemID), player);
            player.currentItem = itemID;
            if (!player.CanPlace((Block)itemID))
                player.Message(Color.Red + "You will not be allowed to place that block.");
        }

        #endregion
    }
}
